home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / AIAT 1.0.1 / Headers / Corpus / IACorpus.h < prev    next >
Encoding:
Text File  |  1997-09-11  |  2.8 KB  |  88 lines  |  [TEXT/CWIE]

  1. // IACorpus.h
  2. //    Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. #pragma once
  5. #ifndef IACorpus_h
  6. #define IACorpus_h
  7.  
  8. #pragma import on
  9.  
  10. #include "IAStorable.h"
  11.  
  12. #pragma IA_BEGIN_EXPORTS
  13.  
  14. class IADoc : public IAOrderedStorable {
  15. public:
  16.     IA_INLINE            ~IADoc() IA_INLINE_DEF()        // no-op dtor def
  17.     // returns the name of a document -- for test applications
  18.     // note: returned array is allocated by IAMallocArray() and should be freed by IAFreeArray().
  19.     virtual byte*        GetName(uint32 *length) const;
  20. };
  21.  
  22. class IADocText : public IAObject {
  23. public:
  24.     IA_INLINE            ~IADocText() IA_INLINE_DEF()    // no-op dtor def
  25.     // Extracts successive segments of the text of the document.
  26.     // Returns number of bytes written into buffer.
  27.     // Returns zero at end of document.
  28.     virtual uint32        GetNextBuffer(byte* buffer, uint32 bufferLen) = 0;
  29.     virtual IADocText*    DeepCopy() const = 0;
  30. };
  31.  
  32. class IADocIterator : public IAObject {
  33. public:
  34.     IA_INLINE            ~IADocIterator() IA_INLINE_DEF()// no-op dtor def
  35.     // Advances the iterator to the next document in a set and returns it.
  36.     // Enumeration is ordered, i.e., each document is LessThan() the next.
  37.     // Returns NULL at the end of the set.
  38.     // Note: returns a new copy of the document.  Clients must delete.
  39.     virtual IADoc*    GetNextDoc() = 0;
  40. };
  41.  
  42. // Thrown if iterator returns items that are not LessThan() next.
  43. IAExceptionCode                CorpusIteratorOutOfOrder = 'VCIO';
  44.  
  45. class IACorpus : public IAObject {
  46. public:
  47.                         IACorpus(uint32 type) : corpusType(type) {}
  48.     IA_INLINE            ~IACorpus() IA_INLINE_DEF()        // no-op dtor def
  49.  
  50.     // Initializes persistent state.
  51.     void                Initialize(IAStorage* storage, IABlockID block);
  52.     // Reads persistent state, including that of all analyses used.
  53.     void                Open(IAStorage* storage, IABlockID block);
  54.     // Flushes any changes to persistent state, including that of all analyses used.
  55.     void                Update(IAStorage* storage, IABlockID block);
  56.  
  57.     // returns a prototype document, for bootstrapping sets of documents
  58.     virtual IADoc*        GetProtoDoc() = 0;
  59.  
  60.     // accesses the text of a document
  61.     virtual IADocText*    GetDocText(const IADoc* doc) = 0;
  62.     
  63.     // Determines set of documents to be indexed. 
  64.     virtual IADocIterator* GetDocIterator();
  65.  
  66.     const uint32 GetCorpusType() const {return corpusType;}
  67.     
  68. protected:
  69.     // Initialize() is implemented by subclasses with the following two methods:
  70.     virtual IABlockSize    InitialSize();
  71.     virtual void        Initializing(IAOutputBlock* output);
  72.     // Open() is implemented by subclasses with the following:
  73.     virtual void        Opening(IAInputBlock* input);
  74.     // Update() is implemented by subclasses with the following two methods:
  75.     virtual IABlockSize    UpdateSize();
  76.     virtual void        Updating(IAOutputBlock* output);
  77. private:
  78.     const uint32        corpusType;
  79.  
  80. };
  81.  
  82. IAExceptionCode                InvalidDocument = 'VCID';
  83.  
  84. #pragma IA_END_EXPORTS
  85.  
  86. #pragma import reset
  87. #endif
  88.